class TheFallenMight_Camera extends Camera;

/*	 ================================================
 *   ===============   variables   ==================
 *   ================================================
 */

var const archetype TheFallenMight_CameraProperties CameraProperties;	  //Constants can be changed in editor.

//CameraTypes
Enum CameraPerspective	
{
   CAM_MapView,	      //Top-Down fixed view
   CAM_Isometric,	  //Camera type with fixed rotation, position can be changed: MousIN 
   CAM_Switcher		  //Automatic movenment from one pos&rot to other
};
var CameraPerspective CameraType;
//Switch variables
var CameraPerspective SwitchCameraType;
var	vector	FinalSwitchLocation;
var	rotator	FinalSwitchRotation;
var float Steps;

/*	 ================================================
 *   ===============   Functions   ==================
 *   ================================================
 */

/**
 * 	 CameraModeSet Setting camera to desired mode
 * 	 @param "CameraPerspective"
 */
function CameraModeSet(CameraPerspective mode)
{
	CameraType = mode;
	`Log("CameraType:"@CameraType);
	if(CameraType == CAM_MapView)
		{

		}
	if(CameraType == CAM_Isometric)
		{

		}
	if(CameraType == CAM_Switcher) 
		{

		}
}



/**
 * setting variables for switcher of the camera
 * 
 */
function SwitchTo(vector FinalLocation,rotator FinalRotation,CameraPerspective nCameraType)
{
		Steps = 0;
		FinalSwitchLocation=FinalLocation;
		FinalSwitchRotation=FinalRotation;
		SwitchCameraType=nCameraType;
		CameraModeSet(CAM_Switcher);
}

/**
 * Query ViewTarget and outputs Point Of View.
 *
 * @param	OutVT		ViewTarget to use.
 * @param	DeltaTime	Delta Time since last camera update (in seconds).
 */
function UpdateViewTarget(out TViewTarget OutVT, float DeltaTime)
{
local vector            Loc, Pos, HitLocation, HitNormal;
local rotator           Rot;
local Actor                     HitActor;
	switch(CameraType)
	{
		case CAM_MapView:
			OutVT.POV.Location = CameraProperties.MapCamPosition;
			OutVT.POV.Rotation = CameraProperties.MapCamRotation;
			break;
		case CAM_Isometric:
			Rot = PCOwner.Rotation;
			Loc = PCOwner.Location;
			Pos = Loc - Vector(Rot) * CameraProperties.CamOffsetDistance;
			HitActor = Trace(HitLocation, HitNormal, Pos, Loc, FALSE, vect(12,12,12));
			OutVT.POV.Location = (HitActor == None) ? Pos : HitLocation;
			OutVT.POV.Rotation = Rot;
			break;
		case CAM_Switcher:
			if(Steps<1) Steps+=DeltaTime/0.7;
			else Steps = 1;
			loc=VLerp(OutVT.POV.Location,FinalSwitchLocation,Steps);
			rot=RLerp(OutVT.POV.rotation, FinalSwitchRotation, Steps, true);
			OutVT.POV.Location = loc;
			OutVT.POV.Rotation = Rot;
			if (Steps == 1)
			{
			CameraModeSet(SwitchCameraType);
			}
			break;
	}
	ApplyCameraModifiers(DeltaTime, OutVT.POV);
//	Super.UpdateViewTarget(OutVT, DeltaTime);
}



DefaultProperties
{
	CameraType=CAM_Isometric;
	CameraProperties=TheFallenMight_CameraProperties'FallenMightGameProperties.Archetypes.CameraProperties';
}
